
public class Test2 {
    public  String name = "admin";
    public  String password = "123456";

    public void logic(String name,String password) throws NameException,PassWordException {
        if(!this.name.equals(name)) {
            System.out.println("用户名错误");
            throw new NameException("你的用户名错误");
        }
        if(!this.name.equals(password)) {
            System.out.println("密码错误");
            throw new PassWordException("你的用户名错误");
        }
    }

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        try {
            test2.logic("admin","12345");
        }catch(NameException e) {
            e.printStackTrace();
            System.out.println("用户名异常");
        }catch (PassWordException e) {
            e.printStackTrace();
            System.out.println("密码异常");
        }
        finally {
            System.out.println("faaaaaaaaaaa");
        }
    }
}
